<xsl:stylesheet version="1.1"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns="http://www.w3.org/2000/svg"
                xmlns:xlink="http://www.w3.org/1999/xlink"
                xmlns:random="http://exslt.org/random"
                xmlns:math="http://exslt.org/math"
                xmlns:exsl="http://exslt.org/common"
                xmlns:temp="http://temp.org/temp"
                extension-element-prefixes="exsl"
                exclude-result-prefixes="random math exsl">
            
	
  	<xsl:template match="room[@id = 'tower_intro']">
	 	<xsl:param name="room-width"/>        
	 	<xsl:param name="room-height"/>
	 	<xsl:variable name="wall-thickness">30</xsl:variable> 
	 	<xsl:variable name="wall-inset" select="$room-width div 4"/> 
	 	<xsl:variable name="floor-inset" select="$room-height div 4"/>
	 	<xsl:variable name="door-width" select="$room-width div 8"/> 
	 	<xsl:variable name="door-height" select="$room-height div 3"/> 
	 	<xsl:variable name="door-x" select="($room-width - $door-width) div 2"/>
	 	<xsl:variable name="door-y" select="$room-height - $floor-inset - $door-height"/>
	 	<rect x="0" y="0" width="{$room-width}" height="{$room-height}" fill="gainsboro" stroke="none"/>
		<path d="M 0 0 L {$wall-inset} {$floor-inset} L {$room-width - $wall-inset} {$floor-inset} L {$room-width} 0 z" fill="dimgray" stroke="black"/>
		<path d="M 0 {$room-height} L {$wall-inset} {$room-height - $floor-inset} L {$room-width - $wall-inset} {$room-height - $floor-inset} L {$room-width} {$room-height} z" fill="dimgray" stroke="black"/>
	 	<rect x="{$door-x}" y="{$door-y}" width="{$door-width}" height="{$door-height}" fill="black" stroke="black"/>
	 	
		<xsl:apply-templates select="inside/thing">
			<xsl:with-param name="base-x" select="$room-width div 4"/>
			<xsl:with-param name="base-y" select="$room-height - $floor-inset div 2"/>
		</xsl:apply-templates>
		<xsl:apply-templates select="window/thing">
			<xsl:with-param name="base-x" select="($room-width * 4) div 5"/>
			<xsl:with-param name="base-y" select="$room-height div 2"/>
		</xsl:apply-templates>
		<xsl:apply-templates select="doorframe/thing">
			<xsl:with-param name="base-x" select="$door-x"/>
			<xsl:with-param name="base-y" select="$door-y"/>
			<xsl:with-param name="width" select="$door-width"/>
			<xsl:with-param name="height" select="$door-height"/>
		</xsl:apply-templates>
		<!-- 
		<xsl:variable name="bar-from-x" select="$room-width div 9"/>
		<xsl:variable name="bar-to-x" select="$room-width  - $room-width div 9"/>
		<xsl:variable name="bar-gap" select="($bar-to-x - $bar-from-x) div 13"/>
		<xsl:call-template name="bars">
			<xsl:with-param name="bar-width">5</xsl:with-param>
			<xsl:with-param name="bar-gap" select="$bar-gap"/>
			<xsl:with-param name="from-x" select="$bar-from-x + $bar-gap div 2"/>
			<xsl:with-param name="to-x" select="$bar-to-x"/>
			<xsl:with-param name="y" select="$room-height div 10"/>
			<xsl:with-param name="bar-height" select="$room-height  - $room-height div 5"/>
		</xsl:call-template>
		 -->
		<!-- 
		<path d="M {-$floor-height} {$room-height - $floor-height} L {($room-width - $floor-height) div 2} {$room-height - $floor-height} l 0 {-$room-height} l {$floor-height} 0 l 0 {$room-height} l {$room-width} 0 L {$room-width + $floor-height} {$room-height + $floor-height} L {-$floor-height} {$room-height + $floor-height} z" fill="dimgray" stroke="black"/>
		 -->
		 <!-- 
		<rect x="{($room-width - $wall-thickness) div 2}" y="{$room-height div 10}" width="{$wall-thickness}" height="{$room-height - $room-height div 5}" fill="dimgray" stroke="black"/>
		 --> 
		
  	</xsl:template>

 	<xsl:template name="bars">
 		<xsl:param name="bar-height"/>
 		<xsl:param name="bar-width"/>
 		<xsl:param name="bar-gap"/>
 		<xsl:param name="from-x"/>
 		<xsl:param name="to-x"/>
 		<xsl:param name="y"/>
 		<xsl:if test="$to-x > $from-x">
 		 	<line x1="{$from-x}" y1="{$y}" x2="{$from-x}" y2="{$y + $bar-height}" stroke="black" stroke-width="{$bar-width}"/>
 		 	<xsl:call-template name="bars">
				<xsl:with-param name="bar-height" select="$bar-height"/>
				<xsl:with-param name="bar-width" select="$bar-width"/>
				<xsl:with-param name="bar-gap" select="$bar-gap"/>
				<xsl:with-param name="from-x" select="$from-x + $bar-gap"/>
				<xsl:with-param name="to-x" select="$to-x"/>
				<xsl:with-param name="y" select="$y"/>
 		 	</xsl:call-template>
 		</xsl:if>
 	</xsl:template>
</xsl:stylesheet>